package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


import java.io.IOException;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {
    @Autowired
    WmMaterialService wmMaterialService;
//    @PostMapping("/upload_picture")
//    public ResponseResult uploadPicture(MultipartFile file) throws IOException {
//       ResponseResult responseResult= wmMaterialService.uploadPicture(file);
//    return responseResult;
//    }
    //图片上传
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile) throws IOException {
        ResponseResult responseResult= wmMaterialService.uploadPicture(multipartFile);
        return responseResult;
    }
   // 展示素材列表
@PostMapping("/list")
    public ResponseResult findList(@RequestBody WmMaterialDto dto) throws IOException {
        ResponseResult result=wmMaterialService.findList(dto);
        return result;
    }
    //收藏
@GetMapping("/collect/{id}")
    public ResponseResult collect(Integer id){
        return wmMaterialService.updateWmMaterial(id);
}
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cancel_collect(Integer id){
        return wmMaterialService.updatecancel_collect(id);
    }
}
